package com.snj.wef.event;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.snj.lib.RankingHolder;
import com.snj.lib.WefmallHolder;
import com.snj.wef.R;


public class EventAdapter extends BaseAdapter {
	
	String tag = "RankingAdapter";
	
	Context context;
	int layout;
	
	
	ArrayList<EventItem> mEventList;
	
	LayoutInflater mInflater = null;
	
	
	public EventAdapter(Context _context, int _layout, ArrayList<EventItem> _newslist) {
		// TODO Auto-generated constructor stub
		
		this.context = _context;
		this.layout = _layout;
		this.mEventList = _newslist;
		
	}
	
	public void Insert(ArrayList<EventItem> mList)
	{
		mEventList.addAll(mList);
	}
	
	public void SetList(ArrayList<EventItem> mList)
	{
		mEventList = mList;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return mEventList.size();
	}

	public EventItem getItem(int position) {
		// TODO Auto-generated method stub
		return mEventList.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
	
		WefmallHolder holder = null;
		
		if(convertView == null)
		{
			mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = mInflater.inflate(layout, parent, false);
			
			holder = new WefmallHolder();
			
			holder.img_title = (ImageView)convertView.findViewById(R.id.Img_eventitemtitle);
			holder.img_content = (ImageView)convertView.findViewById(R.id.img_eventitemcontent);
			
			convertView.setTag(holder);
		}
		else
		{
			holder = (WefmallHolder)convertView.getTag();
		}
		
		
		
		holder.img_title.setImageBitmap(mEventList.get(position).GetTitleImage());
		holder.img_content.setImageBitmap(mEventList.get(position).GetContentImg());
		
		
		return convertView;
	}
	
	
}
